<template>
  <div id="app">
    <el-table :data="filterData" v-loading="">
      <el-table-column prop="data" lable="时间" width="150"></el-table-column>
      <el-table-column prop="name" lable="姓名" width="150"></el-table-column>
      <el-table-column prop="todo" lable="事件" width="150"></el-table-column> 
    </el-table> 
    <el-pagination layout="prev,pager,next,sizes" :total="tableDate.length" :page-sizes="[5,10]" @current-change="click1"
      @size-change="click2"
    >

    </el-pagination>
  </div>
</template>

<script>


export default {
  name: 'App',
  computed:{
    filterData:function (){
      let filterDate=this.tableDate.slice(
        (this.pageNum-1)*this.pageSize,
        (this.pageNum)*this.pageSize
      );  
      return filterDate
    }
  },

  mounted(){
    let _this=this
    setTimeout(() => {
      _this.loading=false
    }, 3000);
  },
  data:
    function  (){
      return {
        loading:true,
        tableDate:[
          {
            data:"2020-12-17",
            name:"JJY",
            todo:"work1"
          },
          {
            data:"2020-12-17",
            name:"JJY",
            todo:"work1"
          },
          {
            data:"2020-12-17",
            name:"JJY",
            todo:"work1"
          },
          {
            data:"2020-12-17",
            name:"JJY",
            todo:"work1"
          },
          {
            data:"2020-12-17",
            name:"JJY",
            todo:"work1"
          },
          {
            data:"2020-12-17",
            name:"JJY",
            todo:"work2"
          },
          {
            data:"2020-12-17",
            name:"JJY",
            todo:"work2"
          },
          {
            data:"2020-12-17",
            name:"JJY",
            todo:"work2"
          },
          {
            data:"2020-12-17",
            name:"JJY",
            todo:"work2"
          },
          {
            data:"2020-12-17",
            name:"JJY",
            todo:"work2"
          }
        ],
        pageSize:10,//一页几条
        pageNum:1//几页
      }
    }
  ,
  methods:{
    click2:function(pageSize){
      console.log(pageSize);
      this.pageSize=pageSize
    },
    click1:function(pageNum){
      console.log(pageNum);
      this.pageNum=pageNum
    }
  },
  components: {
    
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
